package library;

import java.util.Vector;

import javax.swing.table.DefaultTableModel;

public class StudentModel
extends DefaultTableModel
{
	private static final long serialVersionUID = 2873033701092986200L;
	
	public StudentModel(Vector<Student> v)
	{
		super.setColumnIdentifiers(new String[]{"ID", "Name"});
		
		for (int i = 0; i < v.size(); ++i)
		{
			super.addRow(new String[] {Integer.toString(v.elementAt(i).getId()),
					v.elementAt(i).getName()});
		}
		
		
	}
	
	public void add(Student s)
	{
		super.addRow(new String[]
				{
					Integer.toString(s.getId()),
					s.getName()
				});
	}
	
	public void reBuild(Vector<Student> v)
	{
		super.setNumRows(0);
		
		for (int i = 0; i < v.size(); ++i)
		{
			super.addRow(new String[] {Integer.toString(v.elementAt(i).getId()),
					v.elementAt(i).getName()});
		}
	}

	@Override
	public boolean isCellEditable(int row, int column)
	{
		return false;
	}

	
}
